1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.EventController;
26 
27 private import gdk.Device;
28 private import gdk.Event;
29 private import glib.Str;
30 private import glib.c.functions;
31 private import gobject.ObjectG;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * `GtkEventController` is the base class for event controllers.
39  * 
40  * These are ancillary objects associated to widgets, which react
41  * to `GdkEvents`, and possibly trigger actions as a consequence.
42  * 
43  * Event controllers are added to a widget with
44  * [method@Gtk.Widget.add_controller]. It is rarely necessary to
45  * explicitly remove a controller with [method@Gtk.Widget.remove_controller].
46  * 
47  * See the chapter on [input handling](input-handling.html) for
48  * an overview of the basic concepts, such as the capture and bubble
49  * phases of even propagation.
50  */
51 public class EventController : ObjectG
52 {
53 	/** the main Gtk struct */
54 	protected GtkEventController* gtkEventController;
55 
56 	/** Get the main Gtk struct */
57 	public GtkEventController* getEventControllerStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gtkEventController;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gtkEventController;
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GtkEventController* gtkEventController, bool ownedRef = false)
74 	{
75 		this.gtkEventController = gtkEventController;
76 		super(cast(GObject*)gtkEventController, ownedRef);
77 	}
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gtk_event_controller_get_type();
84 	}
85 
86 	/**
87 	 * Returns the event that is currently being handled by the controller.
88 	 *
89 	 * At other times, %NULL is returned.
90 	 *
91 	 * Returns: the event that is currently
92 	 *     handled by @controller
93 	 */
94 	public Event getCurrentEvent()
95 	{
96 		auto __p = gtk_event_controller_get_current_event(gtkEventController);
97 
98 		if(__p is null)
99 		{
100 			return null;
101 		}
102 
103 		return ObjectG.getDObject!(Event)(cast(GdkEvent*) __p);
104 	}
105 
106 	/**
107 	 * Returns the device of the event that is currently being
108 	 * handled by the controller.
109 	 *
110 	 * At other times, %NULL is returned.
111 	 *
112 	 * Returns: device of the event is
113 	 *     currently handled by @controller
114 	 */
115 	public Device getCurrentEventDevice()
116 	{
117 		auto __p = gtk_event_controller_get_current_event_device(gtkEventController);
118 
119 		if(__p is null)
120 		{
121 			return null;
122 		}
123 
124 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) __p);
125 	}
126 
127 	/**
128 	 * Returns the modifier state of the event that is currently being
129 	 * handled by the controller.
130 	 *
131 	 * At other times, 0 is returned.
132 	 *
133 	 * Returns: modifier state of the event is currently handled by @controller
134 	 */
135 	public GdkModifierType getCurrentEventState()
136 	{
137 		return gtk_event_controller_get_current_event_state(gtkEventController);
138 	}
139 
140 	/**
141 	 * Returns the timestamp of the event that is currently being
142 	 * handled by the controller.
143 	 *
144 	 * At other times, 0 is returned.
145 	 *
146 	 * Returns: timestamp of the event is currently handled by @controller
147 	 */
148 	public uint getCurrentEventTime()
149 	{
150 		return gtk_event_controller_get_current_event_time(gtkEventController);
151 	}
152 
153 	/**
154 	 * Gets the name of @controller.
155 	 *
156 	 * Returns: The controller name
157 	 */
158 	public string getName()
159 	{
160 		return Str.toString(gtk_event_controller_get_name(gtkEventController));
161 	}
162 
163 	/**
164 	 * Gets the propagation limit of the event controller.
165 	 *
166 	 * Returns: the propagation limit
167 	 */
168 	public GtkPropagationLimit getPropagationLimit()
169 	{
170 		return gtk_event_controller_get_propagation_limit(gtkEventController);
171 	}
172 
173 	/**
174 	 * Gets the propagation phase at which @controller handles events.
175 	 *
176 	 * Returns: the propagation phase
177 	 */
178 	public GtkPropagationPhase getPropagationPhase()
179 	{
180 		return gtk_event_controller_get_propagation_phase(gtkEventController);
181 	}
182 
183 	/**
184 	 * Returns the `GtkWidget` this controller relates to.
185 	 *
186 	 * Returns: a `GtkWidget`
187 	 */
188 	public Widget getWidget()
189 	{
190 		auto __p = gtk_event_controller_get_widget(gtkEventController);
191 
192 		if(__p is null)
193 		{
194 			return null;
195 		}
196 
197 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
198 	}
199 
200 	/**
201 	 * Resets the @controller to a clean state.
202 	 */
203 	public void reset()
204 	{
205 		gtk_event_controller_reset(gtkEventController);
206 	}
207 
208 	/**
209 	 * Sets a name on the controller that can be used for debugging.
210 	 *
211 	 * Params:
212 	 *     name = a name for @controller
213 	 */
214 	public void setName(string name)
215 	{
216 		gtk_event_controller_set_name(gtkEventController, Str.toStringz(name));
217 	}
218 
219 	/**
220 	 * Sets the event propagation limit on the event controller.
221 	 *
222 	 * If the limit is set to %GTK_LIMIT_SAME_NATIVE, the controller
223 	 * won't handle events that are targeted at widgets on a different
224 	 * surface, such as popovers.
225 	 *
226 	 * Params:
227 	 *     limit = the propagation limit
228 	 */
229 	public void setPropagationLimit(GtkPropagationLimit limit)
230 	{
231 		gtk_event_controller_set_propagation_limit(gtkEventController, limit);
232 	}
233 
234 	/**
235 	 * Sets the propagation phase at which a controller handles events.
236 	 *
237 	 * If @phase is %GTK_PHASE_NONE, no automatic event handling will be
238 	 * performed, but other additional gesture maintenance will.
239 	 *
240 	 * Params:
241 	 *     phase = a propagation phase
242 	 */
243 	public void setPropagationPhase(GtkPropagationPhase phase)
244 	{
245 		gtk_event_controller_set_propagation_phase(gtkEventController, phase);
246 	}
247 }